<?php
class SubcategoriesController extends AppController {
	var $helpers = array('Html','Javascript');
	//var $scaffold = 'admin'; 
	
	function beforeFilter(){
		if (isset($this->params['admin'])){
			$this->layout = 'admin';
		}
	}
	
	function display() {
		$path = func_get_args();

		$count = count($path);
		if (!$count) {
			$this->redirect('/');
		}
		
		$subcategory_code = null;

		if (!empty($path[0])) {
			$subcategory_code = $path[0];
		}
		
		/*if ($path[0] == "contact.php"){
			echo "asdfasdf";
			$this->redirect(Array('controller' => 'pages', 'action' => 'send.php'));
		}*/
		
		$categories = ClassRegistry::init('Category')->find('all');
		
		$subcategory = ClassRegistry::init('Subcategory')->find('first', array('conditions' => array("Subcategory.code" => $subcategory_code)));
		$this->set(compact('categories', 'subcategory'));
		
		$this->render("galeria");
	}
}